<template>
    <div class="Help">
        <!--       公共顶部-->
        <Top>
            <i class="el-icon-arrow-left back" slot="leftPart" @click="goback()"></i>
            <p class="title" slot="midPart">常见问题</p>
        </Top>
        <!--问题列表-->
        <ul class="list">
            <li 
                v-for="(item,index) in infos" 
                :key="index"
                class="animated flipInX"
                :style="{animationDelay:delay(index,true)}">
                <div class="question clearfix" @click="item.is_open=!item.is_open">
                    <p><b>{{index+1}}.</b><span>{{item.question}}</span></p>
                    <i class="arrowR" :class="item.is_open?'el-icon-arrow-down':'el-icon-arrow-right'"></i>
                </div>
                <transition name="slide">
                    <div class="answer" v-if="item.is_open">
                        {{item.answer}}
                    </div>
                </transition>
            </li>
        </ul>
    </div>
</template>

<script>
    //导入相关组件
    import Top from '@/components/smallCom/Top'
    export default {
        name: 'Help',
        components: {
            Top,//顶部信息组件
        },
        created(){
            this.loading = true;
            this.Posthttp('/?method=flower.pub.answer',{},(res)=>{
                this.loading = false;

                if(JSON.parse(res.bodyText).status == 1){
                    this.infos = JSON.parse(res.bodyText).data.info;
                    this.infos.forEach(value=>{
                        this.$set(value,'is_open',false);//全部设为折叠状态
                    })
                }else{
                    this.$message.warning(JSON.parse(res.bodyText).msg); 
                }
            });
        },
        data () {
            return {
                loading:false,
                infos:[],//
            }
        },
        methods:{

        }
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
    .slide-enter-active {
        transition: all .5s linear;
    }
    .slide-enter, .slide-leave-to {
        height: 0;
        opacity: 0;
    }
    .Help{
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        padding-top: .8rem;
        overflow-y: auto;
        background-color: #fff;
        .list{
            background-color: #fff;
            margin-top: .2rem;
            padding-bottom: .9rem;
            li{
                position: relative;
                font-size: .26rem;
                color: #222;
                border-bottom: 1px solid #e4e4e4;
                padding: .2rem .26rem;
                line-height: .42rem;
                .question{
                    width: 100%;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    p{
                        display: flex;
                        justify-content: space-between;
                        align-items: center;
                        flex: 1;
                        b{
                            width: 10%;
                        }
                        span{
                            width: 90%;
                        }
                    }
                    .arrowR{
                        font-size: .3rem;
                        color: #ccc;
                    } 
                }
                .answer{
                    margin-top: .18rem;
                    padding: .2rem 0 0 10%;
                    border-top: 1px dashed #e4e4e4;
                    text-align: justify;
                    color: #888;
                    font-size: .22rem;
                }

            }
        }
    }
</style>
